<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""DTD/xhtml1-strict.dtd">
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="/WEB-INF/c.tld" prefix="c"%>
<%@taglib uri="/WEB-INF/fmt.tld" prefix="fmt"%>
<%@taglib uri="/WEB-INF/fn.tld" prefix="fn"%>
<%@taglib uri="/WEB-INF/el.tld" prefix="el"%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<c:import url="/includes/css_inc.jsp"/>
		<c:import url="/includes/js_inc.jsp"/>
		<script type="text/javaScript">
		
			$(function(){
				
	        	$("#btnSearch").button({
		            icons: {
		                primary: "ui-icon-search"
		            }
		        }).click(function(){
					if(validateEmpty()){
							$("#searchForm").submit();
					} else {
						return false;
					}
		        });
	        	
	        	
	        	$("#btnExport").button({
		            icons: {
		                primary: "ui-icon-arrowthickstop-1-s"
		            }
				}).click(function(){
					if(validateEmpty()){
						
			        		var provinceId =  $("#provinceId option:selected").val();
			        		var transferDailyAcc = $("#transferDailyAcc").val();
			        		
			        		var m = ($("#month option:selected").val() === undefined) ?  '' : $("#month option:selected").val();
			        		var y  = ($("#year option:selected").val() ===  undefined) ?  ''  : $("#year option:selected").val();
			        		
			        		var mTo = ($("#monthTo option:selected").val() === undefined) ?  '' : $("#monthTo option:selected").val();
			        		var yTo = ($("#yearTo option:selected").val() ===  undefined) ?  ''  : $("#yearTo option:selected").val();
			        		
			        		window.location='${pageContext.request.contextPath}/acc6?app=ACC6REPORT&job=export013&provinceId='+provinceId+'&td='+transferDailyAcc+'&m='+m+'&y='+y + '&mTo='+mTo+'&yTo='+yTo;
			        		//window.location='${pageContext.request.contextPath}/acc6?app=ACC6REPORT&showResult='+result+'&job=export&at='+actionType+'&provinceId='+provinceId+'&startDate='+startDate+'&endDate='+endDate+'&td='+transferDailyAcc+'&m='+m+'&y='+y;
					}	
				});
	        	
		        thaiDatepicker("startDate","#","1");
		        thaiDatepicker("endDate","#","1");
			});
			
		</script>
	</head>
	<body>
		<c:import url="/apps/msg.jsp"/>
		<form class="acc67-form" name="searchForm" id="searchForm" action="${pageContext.request.contextPath}/acc6" method="post">
		<input type="hidden" name="app" id="app" value="ACC6REPORT"/>
		<input type="hidden" name="job" id="job" value="ACC6REPORT013"/>
			<table width="100%" class="ui-widget ui-widget-content" border="0">
				<tr>
					<th align="left" class="acc67-header ui-widget-header" colspan="2"><b>${screenCode.ACC6REPORT013}</b></th>
				</tr>
				<tr>
					<td class="bold" width="20%">ประเภท : </td>
					<td>
						<select name="transferDailyAcc" id="transferDailyAcc">
							<option value="">----- เลือก -----</option>
							<option value="6" ${transferDailyAcc == '6' ? 'selected' : ''}>บัญชี 6</option>
							<option value="7" ${transferDailyAcc == '7' ? 'selected' : ''}>บัญชี 7</option>
						</select>
						<span id="$transferDailyAcc" class="red">*</span>
					</td>
				</tr>
<!-- 				<tr> -->
<!-- 					<td class="bold">ประเภทบัญชี : </td> -->
<!-- 					<td> -->
<!-- 						<select name="accountType" id="accountType"> -->
<!-- 							<option value="0">----- เลือก -----</option> -->
<%-- 							<option value="S" ${accountType == 'S' ? 'selected' : ''}>ออมทรัพย์</option> --%>
<%-- 							<option value="D" ${accountType == 'D' ? 'selected' : ''}>กระแสรายวัน</option> --%>
<!-- 						</select> -->
<!-- 						<span id="$accountType" class="red">*</span> -->
<!-- 					</td> -->
<!-- 				</tr> -->
				<tr>
					<td class="bold">จังหวัด : </td>
					<td>
						<c:if test="${userInfo.areaLevel =='3'}">
							<c:forEach var="data" items="${userInfo.listUserProvice}">
								${data.provinceName}
								<input type="hidden" name="provinceId" id="provinceId" value="${data.provinceId}">
							</c:forEach>
						</c:if>
						<c:if test="${userInfo.areaLevel=='1' || userInfo.areaLevel=='2'}">
							<select name="provinceId" id="provinceId">
								<option value="">เลือกทั้งหมด</option>
								<c:forEach var="data" items="${userInfo.listUserProvice}">
									<c:if test="${data.provinceId == provinceId}" var="provinceSeleted"/>
									<option value="${data.provinceId}" ${provinceSeleted?'selected':''}>${data.provinceName}</option>
								</c:forEach>
							</select>
						</c:if>
					</td>
				</tr>
				<tr>
					<td class="bold">
						เดือน / ปี : 
					</td>
					<td>
						<select name="month" id="month">
											<option value="">----- เลือก -----</option>
												<option value="01" ${month == '01' ? 'selected' : ''}>มกราคม</option>
												<option value="02" ${month == '02' ? 'selected' : ''}>กุมภาพันธ์</option>
												<option value="03" ${month == '03' ? 'selected' : ''}>มีนาคม</option>
												<option value="04" ${month == '04' ? 'selected' : ''}>เมษายน</option>
												<option value="05" ${month == '05' ? 'selected' : ''}>พฤษภาคม</option>
												<option value="06" ${month == '06' ? 'selected' : ''}>มิถุนายน</option>
												<option value="07" ${month == '07' ? 'selected' : ''}>กรกฎาคม</option>
												<option value="08" ${month == '08' ? 'selected' : ''}>สิงหาคม</option>
												<option value="09" ${month == '09' ? 'selected' : ''}>กันยายน</option>
												<option value="10" ${month == '10' ? 'selected' : ''}>ตุลาคม</option>
												<option value="11" ${month == '11' ? 'selected' : ''}>พฤศจิกายน</option>
												<option value="12" ${month == '12' ? 'selected' : ''}>ธันวาคม</option>
											</select>
											<span id="$month" class="red">*</span>
								 			
								 			<select name="year" id="year">
												<option value="">----- เลือก -----</option>
												<c:forEach items="${lsBudgetYear}" var="data">
													<c:if test="${year == (data.BUDGET_YEAR - 543)}" var="selected"/>
													<option value="${data.BUDGET_YEAR-543}" ${selected?'selected':''}>${data.BUDGET_YEAR}</option>
												</c:forEach>
											</select>
											<span id="$year" class="red">*</span>
					</td>
				</tr>
				<tr>
					 <td class="bold">
					 	
					 				ถึง เดือน / ปี : 
					 			</td>
					 			<td>
						 			<select name="monthTo" id="monthTo">
											<option value="">----- เลือก -----</option>
												<option value="01" ${monthTo == '01' ? 'selected' : ''}>มกราคม</option>
												<option value="02" ${monthTo == '02' ? 'selected' : ''}>กุมภาพันธ์</option>
												<option value="03" ${monthTo == '03' ? 'selected' : ''}>มีนาคม</option>
												<option value="04" ${monthTo == '04' ? 'selected' : ''}>เมษายน</option>
												<option value="05" ${monthTo == '05' ? 'selected' : ''}>พฤษภาคม</option>
												<option value="06" ${monthTo == '06' ? 'selected' : ''}>มิถุนายน</option>
												<option value="07" ${monthTo == '07' ? 'selected' : ''}>กรกฎาคม</option>
												<option value="08" ${monthTo == '08' ? 'selected' : ''}>สิงหาคม</option>
												<option value="09" ${monthTo == '09' ? 'selected' : ''}>กันยายน</option>
												<option value="10" ${monthTo == '10' ? 'selected' : ''}>ตุลาคม</option>
												<option value="11" ${monthTo == '11' ? 'selected' : ''}>พฤศจิกายน</option>
												<option value="12" ${monthTo == '12' ? 'selected' : ''}>ธันวาคม</option>
											</select>
											<span id="$monthTo" class="red">*</span>
								 			
								 			<select name="yearTo" id="yearTo">
												<option value="">----- เลือก -----</option>
												<c:forEach items="${lsBudgetYear}" var="data">
													<c:if test="${yearTo == (data.BUDGET_YEAR - 543)}" var="selected"/>
													<option value="${data.BUDGET_YEAR-543}" ${selected?'selected':''}>${data.BUDGET_YEAR}</option>
												</c:forEach>
											</select>
											<span id="$year" class="red">*</span>
					 </td>
				</tr>
			
				<tr>
					<td align="center" colspan="2">
						<button type="submit" name="btnSearch" id="btnSearch" class="acc67-button"> ค้นหาข้อมูล </button>
						<button type="button" name="btnExport" id="btnExport" class="acc67-button"> Download </button>
					</td>
				</tr>
			</table>
			
		<br/>
		
		<c:if test="${!empty pageBean.pageData}">
			<fieldset>
				<legend> ผลการค้นหา </legend>
					<table width="100%" class="ui-widget ui-widget-content" border="0">
						<tr>
							<th align="center" class="ui-state-default" width="8%"></span>รหัสเขต</th>
							<th align="center" class="ui-state-default" width="15%"></span>เขต</th>
							<th align="center" class="ui-state-default" width="8%">รหัสจังหวัด</th>
							<th align="center" class="ui-state-default" width="10%">จังหวัด</th>
							<th align="center" class="ui-state-default" >ยอดต้นเดือน</th>
							<th align="center" class="ui-state-default">เงินรับสุทธิ</th>
							<th align="center" class="ui-state-default">เงินจ่ายสุทธิ</th>
							<th align="center" class="ui-state-default">ยอดปลายเดือน</th>
						</tr>
						<c:forEach items="${pageBean.pageData}" var="data" varStatus="x">
							<tr class="grid-tr-${x.count % 2}">
								<td>${data.NHSO_ZONE}</td>
								<td>${data.NHSO_ZONENAME}</td>
								<td>${data.PROVINCE_ID}</td>
								<td>${data.PROVINCE_NAME}</td>
								<td align="right">
									<fmt:formatNumber pattern="#,##0.00" value="${data.ONE}"/>
								</td>
								<td align="right">
									<fmt:formatNumber pattern="#,##0.00" value="${data.TWO}"/>
								</td>
								<td align="right">
									<fmt:formatNumber pattern="#,##0.00" value="${data.THREE}"/>
								</td>
								<td align="right">
									<fmt:formatNumber pattern="#,##0.00" value="${data.FOUR}"/>
								</td>
							</tr>
						</c:forEach>
						<input type="hidden" name="formPage" id="formPage" value="searchForm"/>
						<c:import url="/apps/page.jsp"/>
					</table>
			</fieldset>
		</c:if>
		</form>
	</body>
</html>